package com.ruoyi.web.controller.mk;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mk.domain.MkWggl;
import com.ruoyi.mk.service.IMkWgglService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 网关管理Controller
 * 
 * @author guan
 * @date 2021-12-09
 */
@RestController
@RequestMapping("/mk/wggl")
public class MkWgglController extends BaseController
{
    @Autowired
    private IMkWgglService mkWgglService;

    /**
     * 查询网关管理列表
     */
    @PreAuthorize("@ss.hasPermi('mk:wggl:list')")
    @GetMapping("/list")
    public TableDataInfo list(MkWggl mkWggl)
    {
        startPage();
        List<MkWggl> list = mkWgglService.selectMkWgglList(mkWggl);
        return getDataTable(list);
    }

    /**
     * 导出网关管理列表
     */
    @PreAuthorize("@ss.hasPermi('mk:wggl:export')")
    @Log(title = "网关管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MkWggl mkWggl)
    {
        List<MkWggl> list = mkWgglService.selectMkWgglList(mkWggl);
        ExcelUtil<MkWggl> util = new ExcelUtil<MkWggl>(MkWggl.class);
        return util.exportExcel(list, "网关管理数据");
    }

    /**
     * 获取网关管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('mk:wggl:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(mkWgglService.selectMkWgglById(id));
    }

    /**
     * 新增网关管理
     */
    @PreAuthorize("@ss.hasPermi('mk:wggl:add')")
    @Log(title = "网关管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MkWggl mkWggl)
    {
        return toAjax(mkWgglService.insertMkWggl(mkWggl));
    }

    /**
     * 修改网关管理
     */
    @PreAuthorize("@ss.hasPermi('mk:wggl:edit')")
    @Log(title = "网关管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MkWggl mkWggl)
    {
        return toAjax(mkWgglService.updateMkWggl(mkWggl));
    }

    /**
     * 删除网关管理
     */
    @PreAuthorize("@ss.hasPermi('mk:wggl:remove')")
    @Log(title = "网关管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mkWgglService.deleteMkWgglByIds(ids));
    }
}
